<?php

/**
 * OwnerController
 */

class Application_Controllers_OwnerController{
    function __construct($action) {
        switch ($action) {
            case 'show':
                $this->_show();
                break;
            case 'query':
                $this->_query();
                break;
            case 'showinsert':
                $this->_showInsert();
                break;
            case 'insert':
                $this->insert();
                break;
            case 'modify':
                $this->_modify();
                break;
            default:
               $this->_query();
                break;
        }
    }
    
    private function _showInsert(){     
        $viewOwner = new Application_Views_OwnerView();
        $viewOwner->formInsert();        
    }
    private function set(Application_Models_OwnerModel &$model){
        $model->set_idOwner($_POST['dni']);
        $model->set_lastName($_POST['apellidos']);
        $model->set_name($_POST['nombres']);
        $model->set_gender($_POST['sexo']);
        $model->set_dateBirth($_POST['fechaNacimiento']);
        $model->set_address($_POST['direccion']);
    }
    
    public function insert(){     
        $modelOwner = new Application_Models_OwnerModel();
        $this->set($modelOwner);

        //die($modelOwner->get_idOwner());        
        $modelOwner->insertOwner();        
    }
    
    private function _show(){
        $modelOwner = new Application_Models_OwnerModel();        
        $modelOwner->showOwner();
    }
    
    private function _modify(){
        $modelOwner = new Application_Models_OwnerModel();
         $this->set($modelOwner);
        $modelOwner->updateOwner();
    }

}